/**
 * 描述：动态表单
 * 作者：mlb
 * 日期：2019/6/21
 * 版本：0.0.1
 **/

function spbf(title,dz){
    var player="";
    rapid("#wndzh").window(
        { title: title,
            onshow: function() {
                  rapid("#wndzh").append('<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="600" height="400">\n' +
                    '    <source src=\''+dz+'\' type="video/mp4">' +
                    '</video>');
                 player = videojs('example_video_1',{
                    muted: true,
                    controls : true,
                    height:400,
                    width:600,
                    loop : true,
                    muted :false,
                    preload:'none',
                    autoplay:true

                });
            },
            onHide: function() {
                player.dispose();
            }
          }
    ).show();


}



function jtym(title,dz){
  var player="";
  rapid("#wndtp").window(
      { title: title,
        size: "max",
        onshow: function() {
          rapid("#wndtp").append('<img  src=\''+dz+'\'></img>');
        },
        onHide: function() {
          rapid("#wndtp").empty();
        }
      }
  ).show();


}


(function (E, KIT, RES) {
  "use strict";

  var __URL_ROOT = RES.URL_ROOT + "/formdata";
  var __URL_API = RES.URL_ROOT + "/api";




  //region 导入dateview
  var _setSubGroupPicker = function () {
    // 每当改变了父项，则清空子项，
    // 若没有选择任何父项，则禁用子项

    var _len = arguments.length;

    if (_len == 2) {
      arguments[1].val(null);

      if (rapid.isEmpty(arguments[0])) {
        arguments[1].disabled(true);

      } else {
        arguments[1].disabled(false)
          .dataSource({
            data: "modelId=" + arguments[0]
          });
      }
    } else {
      arguments[2].val(null);

      if (rapid.isEmpty(arguments[0])) {
        arguments[2].disabled(true);

      } else {
        arguments[2].disabled(false)
          .dataSource({
            data: {
              CUSTOMID: arguments[0],
              CUSTOMIDPERENT: arguments[1]
            }
          });
      }
    }

  };

  var _getImportDateView = function () {
    return rapid("#frmImport").dataview();
  };

  var _initImportDateView = function () {
    //导入
    rapid("#frmImport").dataview({
      padding: true,
      fields: [{
        title: "模型表",
        editor: {
          name: "modelId", type: "picker", tip: "请选择模型表...",
          dataSource: {
            url: RES.URL_ROOT + "/dataModel/getModelTableByPicker"
          },
          validator: {
            rules: {required: true}
          },
          onchange: function (e) {
            _setSubGroupPicker(this.value(), e.ui("umdKey"));
          }
        }
      }, {
        title: "选择主键",
        editor: {
          name: "umdKey", type: "picker", tip: "请选择主键...",
          disabled: true,
          dataSource: {
            url: RES.URL_ROOT + "/dataModel/getModelUDMkeyByPicker"
          },
          validator: {
            rules: {required: true}
          }
        }
      }, {
        title: "动态表单", size: "12",
        editor: {
          name: "fnformid", type: "picker", tip: "请选择动态表单...",
          dataSource: {
            textField: "name",
            valueField: "id",
            type: "post",
            url: RES.URL_ROOT + "/formdesigner/findForm",
            data: "type=1"
          },
          validator: {
            rules: {required: true}
          }
        }
      }, {
        title: "更新规则",
        editor: {
          name: "updateRule", type: "picker", tip: "请选择更新规则...",
          dataSource: {
            url: RES.URL_ROOT + "/dataModel/getRuleCode"
          },
          validator: {
            rules: {required: true}
          }
        }
      }, {
        title: "上传数据",
        editor: KIT.tmpWebuploader({
          uploadType: "file",
          accept: {
            title: 'File',
            extensions: 'xls,XLS,xlsx,XLSX',
            mimeTypes: 'application/xls,application/xlsx'
          },
          name: "importFile",
          ratio: 1.2,
          multiple: false,
          fileNumLimit: 20,
          threads: 20,
          hideFileName: true,
          server: "/comm/api/webUpload",
          onUploadSuccess: function (file, response) {

            if (rapid.isUndefined(response)) {
              rapid.warning("系统异常，请刷新。");
              return false;
            }
            if (!rapid.isEmpty(response.message)) {
              rapid.warning(response.message, true);
            }
            if (response.state == 1) {

              var file = $(".importFile").find("input[name='hideFileName']");
              if ((typeof (file) == "undefined") || file.length == 0) {
                var _html = "<input type='hidden' name='hideFileName' value='" + response.data + "'/>";
                $(".importFile .uploader-list").append(_html);
              } else {
                file.val(response.data)
              }
            }
          }
        })
      }]
    });
  };
  //endregion

  rapid.Page.create({
    render: {





      titleBar: E.span({id: "spantitle"}),

      header: E.block(

        E.form({id: "frmDataSearch"}),
          E.form({id: "frmJscUpdate"}),
        "<object id=\"LODOP_OB\" classid=\"clsid:2105C259-1E0C-4534-8141-A753534CB4CA\" width=0 height=0>" +
        "    <embed id=\"LODOP_EM\" type=\"application/x-print-lodop\" width=0 height=0></embed>" +
        "</object>"
      ),
      main: E.grid("grid"),
      other: E.block(

        E.window("wndSon",
          E.form({id: "frmSearch"}),
          E.grid("gridSon")
        ),
        E.window("wndImport",
          E.form({"id": "frmImport"})
        ),
        E.window("wndAdd",
          E("textarea")
            .attr("id", "txtOpinionAdd")
            .addClass("r-border-box", "r-p-sm", "r-corner-all", "r-bd", "r-bd-12-2", "", "", "r-block")
            .css({"box-shadow": "none!important"})
            .attrs({
              "rows": "8"
            })
        )
      )
    },
    methods: {
      _initWnd: function() {
        var __app = this;

        rapid("#wndAdd").window({
          title: "审核不通过意见",
          width: 450,
          maxHeight: 550,
          buttons: [{
            "保存": function(e) {
              var s = this;
              var opinion = $("#txtOpinionAdd").val();

              if(rapid.isEmpty(opinion)) {
                rapid.warning("意见不能为空");
                return;
              }

              rapid.confirm("是否确定审核不通过？", function (yes) {
                if (yes) {
                  var _ids = rapid("#grid").grid().keySelection() + "";

                  rapid("#grid").grid().endSelect();

                  rapid.post({
                    url: __URL_ROOT + "/audit",
                    data: {
                      formId: __app.tag("formid"),
                      ids: _ids,
                      status: "-1",
                      opinion: opinion
                    },
                    success: function () {
                      rapid("#grid").grid().reload();
                      rapid("#wndAdd").window().hide();
                    }
                  });
                }
              });
            }
          }],
          onShow: function() {
          },
          onHide: function() {
            $("#txtOpinionAdd").val("");
          }
        });
      },
      _initGridEvent_: function (formid) {
        var __app = this;
        var __grid_name, __formid_, __row_id_;

        if (rapid.isEmpty(formid)) {
          __grid_name = "grid";
          __formid_ = __app.tag("formid");
          __row_id_ = '';
        } else {
          __grid_name = "gridSon";
          __formid_ = formid;
          __row_id_ = rapid("#grid").grid().selection()[0].ui("conflict_id").val();
        }

        var __grid = rapid("#" + __grid_name).grid()
          .on("add", function (e) {
            var __grid = this;

            rapid.confirm("确定要保存吗？", function (yes) {
              if (yes) {
                var _data;
                if(rapid.isEmpty(__app.tag("formmodel"))) {
                  _data = rapid.extend(true, {}, e.serializeJson(), {
                    attrib_01: __formid_, attrib_02: __app.tag("keyid"),
                    formType: __app.tag("formtype"), row_id: __row_id_,formid: __formid_
                  });
                }else{
                  _data = rapid.extend(true, {}, e.serializeJson(), {
                    lifenodeid:__app.tag("keyid"),
                    formType: __app.tag("formtype"), row_id: __row_id_, formid: __formid_,
                  });
                }

                var __textareaData = e.element.querySelectorAll("textarea");

                $.each(__textareaData,function(i, n){

                  var _name = n.name;

                  _data[_name] = $("#" + n.id).val();
                });

                rapid.post({
                  url: __URL_ROOT + "/add",
                  data: KIT.getEncryptParams(_data),
                  success: function (result) {
                    e.hide();

                    rapid.success("保存成功。", function () {
                      __grid.reload();
                    }, false);
                  }
                });
              }
            });
          })
          .on("beforeAdd", function (e) {
            if (__app.tag("formtype") == "0") {
              var _result = true;
              rapid.post({
                url: __URL_ROOT + "/checkOperationLimits",
                async: false,
                responseMsg: false,
                data: {
                  ids: "",
                  operation: "add",
                  nodeid: __app.tag("keyid")
                },
                fail: function (result, msg) {
                  _result = false;
                  rapid.fail(msg, true);
                }
              });

              return _result;

            }
          })
          .on("update", function (e) {
            var __grid = this;

            rapid.confirm("确定要保存吗？", function (yes) {
              if (yes) {

                var _data;
                if(rapid.isEmpty(__app.tag("formmodel"))) {
                  _data= rapid.extend(true, {}, e.serializeJson(), {
                    formid: __formid_, lifenodeid: __app.tag("keyid"),
                    formType: __app.tag("formtype"),
                    userType: __app.tag("userType"),
                  });
                }else{
                  _data = rapid.extend(true, {}, e.serializeJson(), {
                    lifenodeid:__app.tag("keyid"),
                    formType: __app.tag("formtype"),
                    userType: __app.tag("userType"),row_id: __row_id_,formid:__formid_
                  });
                }

                console.log(_data);
                var __textareaData = e.element.querySelectorAll("textarea");

                $.each(__textareaData,function(i, n){

                  var _name = n.name;

                  _data[_name] = $("#" + n.id).val();
                });

                rapid.post({
                  url: __URL_ROOT + "/update",
                  data: KIT.getEncryptParams(_data),
                  success: function (result) {
                    e.hide();

                    rapid.success("保存成功。", function () {
                      __grid.reload();
                    }, false);
                  }
                });
              }
            });
          })
          .on("beforeUpdate", function (dataview) {
            if (__app.tag("formtype") == "0") {
              var _result = true;
              rapid.post({
                url: __URL_ROOT + "/checkOperationLimits",
                async: false,
                responseMsg: false,
                data: {
                  ids: this.keySelection()[0],
                  operation: "update",
                  nodeid: __app.tag("keyid")
                },
                fail: function (result, msg) {
                  _result = false;
                  rapid.fail(msg, true);
                }
              });

              return _result;

            }

          })
          .on("remove", function (ids) {
            var __grid = this;
            rapid.post({
              url: __URL_ROOT + "/remove",
              data: {
                ids: ids,
                formType: __app.tag("formtype"),
                formid: __app.tag("formid")
              },
              success: function () {
                __grid.reload();
              }
            });
          });

        if (!rapid.isEmpty(__app.tag("uploadFields"))) {

          var __uploadFields = __app.tag("uploadFields"), __i;

          for( __i = 0; __i < __uploadFields.length; __i++){


            __grid.on("download_" + __uploadFields[__i], (function (option){
              return function () {

                if(rapid.isEmpty(option)){
                  return;
                }

                window.open(rapid("#" + __grid_name).grid().selection()[0].ui(option).val());
              };
            })(__uploadFields[__i]));
          }
        }

        if (!rapid.isEmpty(__app.tag("_son_uploadFields"))) {

          var __uploadFields = __app.tag("_son_uploadFields"), __i;

          for( __i = 0; __i < __uploadFields.length; __i++){


            __grid.on("download_" + __uploadFields[__i], (function (option){
              return function () {

                if(rapid.isEmpty(option)){
                  return;
                }

                window.open(rapid("#" + __grid_name).grid().selection()[0].__p_data[option]);
              };
            })(__uploadFields[__i]));
          }
        }
      },
      _getGridMultiActions: function (formid) {
        var __app = this,
          __user_type = __app.tag("userType"),

          __actions = [],
              __formid_,__grid_name,
              __row_id_;

          if (!rapid.isEmpty(__user_type)) {
              __user_type = __user_type.toUpperCase();

              if (rapid.isEmpty(formid)) {
                  __formid_ = __app.tag("formid");
                  __grid_name = "grid";
                  __row_id_ = '';
              } else {
                  __formid_ = formid;

              }

              if(__app.tag("formtype") == "1" && __user_type != 'FORM_DATA_ROLE_TYPE_SUBMIT' && __user_type != 'FORM_DATA_ROLE_TYPE_AUDIT' && __user_type != 'FORM_DATA_ROLE_TYPE_RELEASE'){






              }



          }

        return __actions;
      },
      _getGridSingleActions: function () {
        var __app = this,
          __level = __app.tag("level"),
          __user_type = __app.tag("userType"),
          __soninfo = __app.tag("soninfo"),
          __actions = [];

        if (!rapid.isEmpty(__user_type)) {
          __user_type = __user_type.toUpperCase();



          if (__user_type == "FORM_DATA_ROLE_TYPE_SUBMIT") {
            __actions.push({
              text: "提交",
              toolbar: false,
              filter: function (item) {

                if (item.attrib_101 == '-2' || item.attrib_101 == '-9') {
                  return true;
                } else {
                  return false;
                }
              },
              handler: function () {
                var _this = this;
                rapid.confirm("是否确定提交？", function (yes) {
                  if (yes) {
                    var _ids = _this.keySelection() + "";
                    rapid("#grid").grid().endSelect();

                    rapid.post({
                      url: __URL_ROOT + "/audit",
                      data: {
                        formId: __app.tag("formid"),
                        ids: _ids,
                        status: "0"
                      },
                      success: function () {
                        rapid("#grid").grid().reload();
                      }
                    });
                  }
                });
              }
            });

          } else if (__user_type == "AUDIT" || __user_type == "FORM_DATA_ROLE_TYPE_AUDIT") {
            __actions.push({
              text: "审核通过",
              toolbar: false,
              filter: function (item) {


             /*   if (__level == 'level-one' && item.attrib_141 == 'S') {
                  return true;
                } else if (__level == 'level-two' && item.attrib_142 == 'S') {
                  return true;
                } else if (__level == 'level-three' && item.attrib_143 == 'S') {
                  return true;
                } else if (__level == 'level-four' && item.attrib_144 == 'S') {
                  return true;
                } else if (__level == 'level-five' && item.attrib_145 == 'S') {
                  return true;
                } else {
                  return false;
                }*/  return true;
              },
              handler: function () {
                var _this = this;
                rapid.confirm("是否确定审核通过？", function (yes) {
                  if (yes) {
                    var _ids = _this.keySelection() + "";

                    rapid("#grid").grid().endSelect();

                    rapid.post({
                      url: __URL_ROOT + "/audit",
                      data: {
                        formId: __app.tag("formid"),
                        ids: _ids,
                        status: "1"
                      },
                      success: function () {
                        rapid("#grid").grid().reload();
                      }
                    });
                  }
                });
              }
            });
            __actions.push({
              text: "审核不通过",
              toolbar: false,
              filter: function (item) {

              /*  if (__level == 'level-one' && item.attrib_141 == 'S') {
                  return true;
                } else if (__level == 'level-two' && item.attrib_142 == 'S') {
                  return true;
                } else if (__level == 'level-three' && item.attrib_143 == 'S') {
                  return true;
                } else if (__level == 'level-four' && item.attrib_144 == 'S') {
                  return true;
                } else if (__level == 'level-five' && item.attrib_145 == 'S') {
                  return true;
                } else {
                  return false;
                }*/ return true;
              },
             handler: function () {
                var _this = this;

                __app._initWnd();
                rapid("#wndAdd").window().show();
              }

            });
            __actions.push({
              text: "反审",
              toolbar: false,
              filter: function (item) {
              /*  if (__level == 'level-one' && item.attrib_141 == 'Y') {
                  return true;
                } else if (__level == 'level-two' && item.attrib_142 == 'Y') {
                  return true;
                } else if (__level == 'level-three' && item.attrib_143 == 'Y') {
                  return true;
                } else if (__level == 'level-four' && item.attrib_144 == 'Y') {
                  return true;
                } else if (__level == 'level-five' && item.attrib_145 == 'Y') {
                  return true;
                } else {
                  return false;
                }*/return true;
              },
              handler: function () {
                var _this = this;
                rapid.confirm("是否确定反审？", function (yes) {
                  if (yes) {
                    var _ids = _this.keySelection() + "";

                    rapid("#grid").grid().endSelect();

                    rapid.post({
                      url: __URL_ROOT + "/audit",
                      data: {
                        formId: __app.tag("formid"),
                        ids: _ids,
                        status: "-9"
                      },
                      success: function () {
                        rapid("#grid").grid().reload();
                      }
                    });
                  }
                });
              }
            });
          }


        }


        /**
         * 子模型
         */
        if (!rapid.isEmpty(__soninfo) && !rapid.isEmpty(__user_type)) {

          var __son_forms = __soninfo.split(',');
          $.each(__son_forms, function (index, j) {

            var __soninfo_ = j;
            var __son_form_ = __soninfo_.split('|');

              var __formid = __son_form_[0],
              __formname = __son_form_[1],
              __formcode = __son_form_[2];
            __actions.push({
              text: __formname,
              toolbar: true,
              handler: function () {
                var _this = this;
                var _id = _this.keySelection() + "";

                if (rapid.isEmpty(_id) || _id == "-") {
                  return;
                }

                rapid.get({
                  url: __URL_ROOT + "/getFormFieldByFormid",
                  data: {formid: __formid},
                  success: function (fieldParams) {
                    if (!rapid.isEmpty(fieldParams)) {

                      var _son_fields = [],
                        __son_searchFields = [],
                        _son_uploadFields = [],
                        __son_len = fieldParams.length,
                        __son_field_param, _i;

                      for (_i = 0; _i < __son_len; _i++) {

                        __son_field_param = fieldParams[_i];

                        var __son_field = rapid.kit.formFieldFactroy(__son_field_param);
                        _son_fields.push(__son_field);

                          if(!rapid.isEmpty(__son_field.editor.uploadType)){

                          __son_field_param.type = "download";
                          _son_fields.push(rapid.kit.formFieldFactroy(__son_field_param));
                          _son_uploadFields.push(__son_field.editor.name);
                        }

                        //组装查询的dataview
                        if (__son_field_param.is_search == "1") {
                          __son_searchFields.push(rapid.kit.formFieldFactroy(__son_field_param, true));
                        }
                      }

                      __app.tag("_son_uploadFields", _son_uploadFields);

                        if(__formcode=='rq086'){
                            _son_fields = _son_fields.concat([{
                              title: "智能标签", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('智能标签','/content/rqsp/t2.png');\"  >查看详情</button></center>"
                              }
                            },{
                              title: "电子锁数据", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('电子锁数据','/content/rqsp/t3.png');\"  >查看详情</button></center>"
                              }
                            },{
                                title: "装货记录", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('装货记录','/content/rqsp/zhsp.mp4');\"  >装货记录</button></center>"
                                }
                            },]);
                        }

                        if(__formcode=='rqhb001'){
                            _son_fields = _son_fields.concat([{
                              title: "智能标签", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('智能标签','/content/rqsp/t2.png');\"  >查看详情</button></center>"
                              }
                            },{
                              title: "电子锁数据", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('电子锁数据','/content/rqsp/t3.png');\"  >查看详情</button></center>"
                              }
                            },{
                                title: "装货记录", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('装货记录','/content/rqsp/zhsp.mp4');\"  >装货记录</button></center>"
                                }
                            },]);
                        }

                        if(__formcode=='rq032'){
                            _son_fields = _son_fields.concat([{
                                title: "卸货视频", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('卸货视频','/content/rqsp/xhsp.mp4');\"  >卸货视频</button></center>"
                                }
                            },]);
                        }


                        if(__formcode=='rq084'){
                            _son_fields = _son_fields.concat([{
                              title: "GPS记录", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('GPS记录','/content/rqsp/t4.png');\"  >查看详情</button></center>"
                              }
                            },{
                              title: "电子锁数据", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('电子锁数据','/content/rqsp/t5.png');\"  >查看详情</button></center>"
                              }
                            },{
                              title: "报警日志", name: "znbq", width: 120, frozen: false,editor:false,
                              action: function(e) {
                                return "<center><button  style='width: 70px' onclick=\"jtym('报警日志','/content/rqsp/t6.png');\"  >查看详情</button></center>"
                              }
                            },{
                                title: "卸货视频", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('卸货视频','/content/rqsp/xhsp.mp4');\"  >卸货视频</button></center>"
                                }
                            },]);
                        }
                      if(__formcode=='rq033'){
                        _son_fields = _son_fields.concat([{
                          title: "GPS记录", name: "znbq", width: 120, frozen: false,editor:false,
                          action: function(e) {
                            return "<center><button  style='width: 70px' onclick=\"jtym('GPS记录','/content/rqsp/t4.png');\"  >查看详情</button></center>"
                          }
                        },{
                          title: "电子锁数据", name: "znbq", width: 120, frozen: false,editor:false,
                          action: function(e) {
                            return "<center><button  style='width: 70px' onclick=\"jtym('电子锁数据','/content/rqsp/t5.png');\"  >查看详情</button></center>"
                          }
                        },{
                          title: "报警日志", name: "znbq", width: 120, frozen: false,editor:false,
                          action: function(e) {
                            return "<center><button  style='width: 70px' onclick=\"jtym('报警日志','/content/rqsp/t6.png');\"  >查看详情</button></center>"
                          }
                        },]);
                      }

                        if(__formcode=='rq083'){
                            _son_fields = _son_fields.concat([{
                                title: "储存视频", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('存储视频','/content/rqsp/ccsp.mp4');\"  >储存视频</button></center>"
                                }
                            },]);
                        }

                        if(__formcode=='rq031'){
                            _son_fields = _son_fields.concat([{
                                title: "储存视频", name: "ckxq", width: 120, frozen: false,editor:false,
                                action: function(e) {
                                    return "<center><button  style='width: 70px' onclick=\"spbf('存储视频','/content/rqsp/ccsp.mp4');\"  >储存视频</button></center>"
                                }
                            },]);
                        }

                      /*_son_fields = _son_fields.concat([{
                        title: "创建人", name: "created_by_name", width: 100
                      }, {
                        title: "创建时间", name: "created", width: 100, formatter: "date:yyyy-MM-dd"
                      }, {
                        title: "修改人", name: "last_upd_by_name", width: 100
                      }, {
                        title: "修改时间", name: "last_upd", width: 100, formatter: "date:yyyy-MM-dd"
                      }]);*/

                      //服务与配置变更管理添加操作按钮
                      if (__formcode=='fwpzbggl') {
                        _son_fields = _son_fields.concat([{
                          title: "操作", name: "fwpzbggl", width: 400, frozen: false, editor: false,
                          action: function (e) {
                            return "<center>" +
                                "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"mocExecClick('" + e.conflict_id + "');\" >执行操作</button></center>"

                          }
                        }]);
                      }

                      //智能合约信息操作按钮
                      if (__formcode=='znhy') {
                        _son_fields = _son_fields.concat([{
                          title: "操作", name: "znhy", width: 400, frozen: false, editor: false,
                          action: function (e) {
                            return "<center>" +
                                "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "','pr001');\" >部署</button>  " +
                                "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "');\" >变更</button>  " +
                                "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "');\" >删除</button>  " +
                                "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "');\" >冻结</button></center>"
                          }
                        }]);
                      }


                      rapid("#wndSon").window({
                        title: __formname,
                        size: "max",
                        onInit: function () {

                          // rapid("#gridSon").grid().fields(_son_fields);
                        },
                        onShow: function () {

                          __app._initGridSon(_son_fields, __formid);

                          __app._initSearchView(__son_searchFields, __formid, _id);

                          var __grd = rapid("#gridSon").grid();
                          //var __ui = rapid("#grid").grid().selection()[0].ui();

                          //rapid("#gridSon").grid().resize();
                          if(rapid.isEmpty(__app.tag("formmodel"))) {
                            //rapid("#gridSon").grid().resize();
                            __grd.load({
                              data: {
                                form_id: __formid,
                                keyid: __app.location().params.keyid,
                                row_id: _id
                              }
                            });
                          }else{
                            __grd.load({
                              data: {
                                form_id: __formid,
                                keyid: __app.location().params.keyid,
                                row_id: _id
                              }
                            });
                          }

                        },
                        onHide: function () {
                          rapid("#gridSon").grid().clear();
                          rapid("#frmSearch").dataview().reset();
                        }
                      }).show();

                    }
                  }
                });
              }
            });
          })

        }
        return __actions;
      },


      _getGridActions: function (formid) {
        var __app = this,
          __actions = [],
          __formid_,__grid_name,
          __row_id_,
          __user_type = __app.tag("userType");

        if (!rapid.isEmpty(__user_type)) {
          __user_type = __user_type.toUpperCase();

          if (rapid.isEmpty(formid)) {
            __formid_ = __app.tag("formid");
            __grid_name = "grid";
            __row_id_ = '';
          } else {
            __formid_ = formid;
            __grid_name = "gridSon";
            __row_id_ = rapid("#grid").grid().selection()[0].ui("conflict_id").val();
          }



          if (__app.tag("formtype") == "1" && (__user_type == 'FORM_DATA_ROLE_TYPE_SUBMIT' || __user_type == 'FORM_DATA_ROLE_TYPE_AUDIT' || __user_type == 'FORM_DATA_ROLE_TYPE_RELEASE')) {
            __actions.push({
              toolbar: true,
              icon: "fa-file-import",
              text: "导入数据",
              handler: function () {
                var formid = __formid_;
                rapid("#wndImport").window({
                  title: "数据导入",
                  buttons: [{
                    "导入": function (s) {
                      var _this = this;
                      var __dataview = _getImportDateView();

                      if (!__dataview.valid()) {
                        return;
                      }
                      var fileName = $(".importFile ").find("input[name='hideFileName']").val();
                      if (rapid.isEmpty(fileName)) {
                        rapid.warning("请上传要导入的数据！");
                        return false;
                      }

                      rapid.confirm("确定导入吗？", function (e, r) {
                        if (!e) {
                          return;
                        }
                        var data = __dataview.serializeJson();
                        data.importFile = fileName;
                        data.rowid = __row_id_;
                        s.disabled(true);
                        rapid.post({
                          url: RES.URL_ROOT + "/dataModel/powerImport",
                          data: data,
                          success: function (result) {
                            rapid.success("导入成功。");
                            _this.hide();
                            rapid("#" + __grid_name).grid().reload();
                          },
                          complete: function () {
                            s.disabled(false);
                          }
                        });
                      });
                    }
                  }],
                  onInit: function () {
                    _initImportDateView();
                  },
                  onShow: function () {

                    rapid.post({
                      url: RES.URL_ROOT + "/dataModel/getModelTableByPicker",
                      data: {"modelId":  __app.tag("model_id")},
                      success: function (result) {
                        if (!rapid.isEmpty(result) && result.length > 0) {
                          _getImportDateView().ui("modelId").value(result[0].value).text(result[0].text).disabled(true).trigger("change");
                        }
                      }
                    });




                    rapid.post({
                      url: RES.URL_ROOT + "/formdesigner/findForm",
                      data: {type: "1", "id": __formid_},
                      success: function (result) {
                        if (!rapid.isEmpty(result) && result.length > 0) {
                          _getImportDateView().ui("fnformid").value(result[0].id).text(result[0].name).disabled(true);
                        }
                      }
                    });

                  },
                  onHide: function () {
                    _getImportDateView().reset();
                    $(".importFile .uploader-list").html("");

                  }
                }).show();
              }
            });
          }


          if (__user_type == 'FORM_DATA_ROLE_TYPE_SUBMIT' || __user_type == 'FORM_DATA_ROLE_TYPE_AUDIT' || __user_type == 'FORM_DATA_ROLE_TYPE_RELEASE') {
            __actions.push({
              toolbar: true,
              icon: "fa-file-export",
              text: "导出至Excel文件",
              handler: function () {
                if (this.recordCount() > 0) {
                  var __search_params = rapid("#frmDataSearch").dataview().serializeJson();
                  __search_params = $.extend({}, __search_params, {
                    attrib_01: __formid_,
                    attrib_02: __app.tag("keyid")
                  });
                  var json = rapid.nvl(__search_params, {});
                  var query = "";
                  for (var key in json) {
                    if (!rapid.isEmpty(json[key])) {
                      query += key + "=" + json[key] + "&";
                    }
                  }

                  query = query.substring(0, query.length - 1);

                  window.location.href = __URL_ROOT + "/export?" + query;
                }
              }
            });
          }
        }

        return __actions;
      },
      _setGridCURD: function (options) {
        var __app = this;

        if (__app.tag("formtype") == "1") {
          options.addable = false;
          options.updatable = false;
          options.removable = false;
        }

        var __user_type = __app.tag("userType");

        if (!rapid.isEmpty(__user_type)) {
          __user_type = __user_type.toUpperCase();

          if (__user_type == "FORM_DATA_ROLE_TYPE_SUBMIT") {

            options.addable = true;
            options.updatable = true;
            options.removable = true;

          } else if (__user_type == "AUDIT" || __user_type == "FORM_DATA_ROLE_TYPE_AUDIT") {

            options.addable = false;
            options.updatable = true;
            options.removable = false;
          } else if (__user_type == "FORM_DATA_ROLE_TYPE_ENROLL") {

            options.addable = false;
            options.updatable = false;
            options.removable = false;
          }
        }
      },
      _initGrid_: function (fields) {

        var __app = this;

        var _gridOption = {
          height: function () {
            return rapid(__app.main()).height();
          },
          window:{size:"max"},
          rowId:true,
          addable: true,
          updatable: true,
          removable: true,
          detailed: true,
          rowHeight: "auto",
          dataSource: {
            url: __URL_ROOT + "/getFormData",
            data: {
              form_id: __app.tag("formid"),
              keyid: __app.location().params.keyid
            }
          },
          pageable: true,
          keyFields: "conflict_id",
          paramFields: ["conflict_id", "row_id"],
          dataview: {
            colSize: __app.tag("colSize")
          },
          fields: fields
        };

        if (__app.tag("searchFieldCount") > 0) {
          _gridOption.actions = __app._getGridActions();
        }

        var __user_type = __app.tag("userType");

        if (!rapid.isEmpty(__user_type)) {
          __app._setGridCURD(_gridOption);
          _gridOption.multiActions = __app._getGridMultiActions( __app.tag("formid"));
          _gridOption.singleActions = __app._getGridSingleActions();
        }

        var __grd = rapid("#grid").grid(_gridOption);

        this._initGridEvent_();

        __grd.load();
      },
      _initGridSon: function (fields, formid) {
        var __app = this;

        var _gridOption = {
          height: function () {
            return rapid(__app.main()).height();;
          },
          addable: true,
          updatable: true,
          removable: true,
          detailed: true,
          dataSource: {
            url: __URL_ROOT + "/getFormData"
          },
          pageable: true,
          keyFields: "conflict_id",
          paramFields: ["conflict_id", "row_id"],
          dataview: {
            colSize: __app.tag("colSize")
          },
          window: {
            size: "lg"
          },
          fields: fields
        };

        _gridOption.actions = __app._getGridActions(formid);
        var __grd = rapid("#gridSon").grid(_gridOption);

        this._initGridEvent_(formid);

        this.tag("gridSon", __grd);
      },
      _initSearchDataView: function (searchFields) {
        var __app = this;
        if (searchFields.length > 0) {
          searchFields.push({
            template: function () {
              return E.view({cssClass: "r-nowrap"},
                E.button({
                  id: "btnSearch", icon: "fa-search", cssClass: "r-m-r", text: "搜索"
                })
              );
            }
          });



          rapid("#frmDataSearch").dataview({
            colSize: 0,
            padding: false,
            fields: searchFields,
            oninit: function () {
              rapid.ui("#btnSearch").on("click", function () {
                var __search_params = rapid("#frmDataSearch").dataview().serializeJson();

                if(rapid.isEmpty(__app.tag("formmodel"))) {
                  __search_params.attrib_01 = __app.tag("formid");
                  __search_params.attrib_02 = __app.tag("keyid");
                }else{

                  __search_params.keyid = __app.tag("keyid");
                  __search_params.form_id= __app.tag("formid");
                }

                rapid("#grid").grid().load({
                  data: __search_params
                });
              });



            }
          });
        }
      },
      _initSearchView: function (searchFields, sonFormId, frowId) {

        rapid("#frmSearch").empty().removeData();

        var __app = this;
        if (searchFields.length > 0) {
          searchFields.push({
            template: function () {
              return E.view({cssClass: "r-nowrap"},
                E.button({
                  id: "btnSonSearch", icon: "fa-search", cssClass: "r-m-r", text: "搜索"
                })
              );
            }
          });



          rapid("#frmSearch").dataview({
            colSize: 0,
            padding: false,
            fields: searchFields,
            oninit: function () {
              rapid.ui("#btnSonSearch").on("click", function () {
                var __search_params = rapid("#frmSearch").dataview().serializeJson();



                if(rapid.isEmpty(__app.tag("formmodel"))) {
                  __search_params.attrib_01 = sonFormId;
                  __search_params.attrib_02 = __app.tag("keyid");;
                }else{

                  __search_params.keyid =sonFormId;
                  __search_params.form_id=  __app.tag("keyid");
                }
                __search_params.row_id = frowId;

                rapid("#gridSon").grid().load({
                  data: __search_params
                });

              });
            }
          });
        }
      }
    }
  })({
    request: {
      url: __URL_ROOT + "/getFnFormByCode",
      data: {code: rapid.parseUrl().params.code}
    }
  }).on("ready", function () {
    var __app = this;
    var _fnForm = __app.resource();

    if (rapid.isEmpty(_fnForm)) {
      rapid.error("动态表单不存在。");
      return;
    }

    rapid("#spantitle").html(_fnForm.name);

    __app.tag("colSize", _fnForm.colsize == 0 ? "auto" : _fnForm.colsize);
    __app.tag("formid", _fnForm.id);
    __app.tag("formtype", _fnForm.type);
    __app.tag("formcode", _fnForm.code);
    __app.tag("formmodel", _fnForm.model);
    __app.tag("keyid", __app.location().params.keyid);
    __app.tag("soninfo", _fnForm.soninfo);

    rapid.get({
      url: __URL_ROOT + "/getFormFieldByFormid",
      data: {formid: _fnForm.id},
      success: function (fieldParams) {
        if (!rapid.isEmpty(fieldParams)) {
          var __form_type = __app.tag("formtype");

          if (__form_type == "0") {
            rapid.post({
              url: __URL_ROOT + "/getLifecycExampleNodePer",
              async: false,
              data: {
                nodeId: __app.tag("keyid")
              },
              success: function (result) {
                if (!rapid.isEmpty(result)) {
                  __app.tag("userType", result.attrib_02);
                }
              }
            });

          } else {
            rapid.post({
              url: __URL_ROOT + "/getFormDataUserRole",
              async: false,
              data: {
                form_id: __app.tag("formid")
              },
              success: function (result) {
                if (!rapid.isEmpty(result)) {
                  __app.tag("userType", result.attrib_01);
                  __app.tag("level", result.rolecode);
                }
              }
            });
          }


          rapid.post({
            url: RES.URL_ROOT + "/formdesigner/getImportModelTable",
            async: false,
            data: {
              form_id: __app.tag("formid")
            },
            success: function (result) {
              if (!rapid.isEmpty(result)) {
                __app.tag("model_id", result.conflict_id);

              }
            }
          });


          var _fields = [],
            _searchFields = [],
              _jscUpdateFields = [],
            _uploadFields = [],
            __len = fieldParams.length,
            __has_sum = false,
            __field_param, __i;








          for (__i = 0; __i < __len; __i++) {
            __field_param = fieldParams[__i];

            if (!__has_sum && __field_param.is_sum == "1") {

              __has_sum = true;
            }

            var _field_ = rapid.kit.formFieldFactroy(__field_param);



            _fields.push(_field_);

            if(!rapid.isEmpty(_field_.editor.uploadType)){

              __field_param.type = "download";
              _fields.push(rapid.kit.formFieldFactroy(__field_param));
              _uploadFields.push(_field_.editor.name);
            }




            //组装查询的dataview
            if (__field_param.is_search == "1") {
              _searchFields.push(rapid.kit.formFieldFactroy(__field_param, true));

            }
          }






          __app.tag("uploadFields",_uploadFields);

          if (__has_sum) {

            _fields.unshift({
              title: "汇总项",
              name: "total",
              editor: {
                name: "total"
              }
            });
          }
          __app.tag("searchFieldCount", _searchFields.length);
 /*           if (!rapid.isEmpty(__app.tag("userType"))) {
              if (!rapid.isEmpty(__app.tag("formmodel"))) {


                _fields = _fields.concat([{
                  title: "审核状态", name: "audit_state_cn", width: 100, frozen: false
                }, {
                  title: "审核人姓名", name: "audit_by_name", width: 100, frozen: false
                }, {
                  title: "审核时间",
                  name: "audit_date",
                  width: 100,
                  formatter: "date:yyyy-MM-dd",
                  frozen: false
                },]);

              } else {
                _fields = _fields.concat([{
                  title: "审核状态", name: "attrib_101_cn", width: 100, frozen: false
                }, {
                  title: "审核人姓名", name: "attrib_104", width: 100, frozen: false
                }, {
                  title: "审核时间", name: "attrib_103", width: 100, formatter: "date:yyyy-MM-dd", frozen: false
                },]);
              }
            }*/
       /*   _fields = _fields.concat([{
            title: "创建人", name: "created_by_name", width: 100
          }, {
            title: "创建时间", name: "created", width: 100, formatter: "date:yyyy-MM-dd"
          }, {
            title: "修改人", name: "last_upd_by_name", width: 100
          }, {
            title: "修改时间", name: "last_upd", width: 100, formatter: "date:yyyy-MM-dd"
          }]);*/

        /*  if(!rapid.isEmpty( __app.tag("formmodel"))){
            _fields = _fields.concat([{
              title: "链上信息", name: "hash_val", width: 200, editor: false,formatter:function (value, text, css) {
                var val="未上链";
                if(value!=null && value!='')
                  return "<b><a href='/sysadmin/block/transDetail/"+value+"' style='text-decoration:none;' target='_blank'>查看链上信息</a></b>";
                else
                  return val;
              }
            }]);
          }else{
            _fields = _fields.concat([{
              title: "链上信息", name: "attrib_99", width: 200, editor: false,formatter:function (value, text, css) {
                var val="未上链";
                if(value!=null && value!='')
                  return "<b><a href='/sysadmin/block/transDetail/"+value+"' style='text-decoration:none;' target='_blank'>查看链上信息</a></b>";
                else
                  return val;
              }
            }]);
          }*/

          //应用服务单元管理动态表单添加操作按钮
          if (rapid.parseUrl().params.code == 'yyfwdygl') {
            _fields = _fields.concat([{
              title: "操作", name: "yyfwdygl", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"uploadToRemoteClick('" + e.conflict_id + "');\" >部署</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"updateRemoteAppClick('" + e.conflict_id + "');\" >更新</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"startRemoteAppClick('" + e.conflict_id + "');\" >启动</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"stopRemoteAppClick('" + e.conflict_id + "');\" >停止</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "');\" >状态监控</button></center>"
              }
            }]);
          }

           //用户管理理动态表单添加操作按钮
          if (rapid.parseUrl().params.code == 'yhgl') {
            _fields = _fields.concat([{
              title: "操作", name: "yhgl", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"dcmxpc('" + e.conflict_id + "');\" >证书申请</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"dcmxpc('" + e.conflict_id + "');\" >证书延期</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"dcmxpc('" + e.conflict_id + "');\" >证书撤销</button></center>"
              }
            }]);
          }

          //主机监控动态表单添加操作按钮
          if (rapid.parseUrl().params.code == 'zjjk') {
            _fields = _fields.concat([{
              title: "操作", name: "zjjk", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                   "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"dcmxpc('" + e.conflict_id + "');\" >主键监控</button></center>"
              }
            }]);
          }

          //应用服务上链信息操作按钮
          if (rapid.parseUrl().params.code == 'yyfwslxx') {
            _fields = _fields.concat([{
              title: "操作", name: "yyfwslxx", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"dcmxpc('" + e.conflict_id + "');\" >交易详情</button></center>"
              }
            }]);
          }

          //主机信息管理操作按钮
          if (rapid.parseUrl().params.code == 'zjxxgl') {
            _fields = _fields.concat([{
              title: "操作", name: "zjxxgl", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"MachineOnClick('" + e.attrib_05 + "','" + e.attrib_06 + "');\" >主机信息监控</button></center>"
              }
            }]);
          }

          //节点信息操作按钮
          if (rapid.parseUrl().params.code == 'jdxx') {
            _fields = _fields.concat([{
              title: "操作", name: "jdxx", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"nodeMonitorOnClick('" + e.attrib_08 + "','" + e.attrib_04 + "');\" >节点信息监控</button></center>"
              }
            }]);
          }

          //智能合约信息操作按钮
          if (rapid.parseUrl().params.code =='znhy') {
            _fields = _fields.concat([{
              title: "操作", name: "znhy", width: 400, frozen: false, editor: false,
              action: function (e) {
                return "<center>" +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "','pr001');\" >部署</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "');\" >变更</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "','" + e.attrib_10 + "');\" >删除</button>  " +
                    "<button   class=\"btn btn-primary btn-w-m\" style='color: #fff;border: none;padding: 5px 5px;border-radius: 5px;background: #12b886;' onclick=\"yhNodeClick('" + e.conflict_id + "');\" >冻结</button></center>"
              }
            }]);
          }


          __app._initSearchDataView(_searchFields);

          __app._initGrid_(_fields);
        }
      }
    });


  }).init();

})(rapid.html.Element, rapid.kit, rapid.res);

//节点方法提醒弹窗
function yhNodeClick(){
  rapid.confirm("确定要执行吗？", function(e) {
   console.log(e);
  });
  __grid.reload();
}

//主机信息管理跳转到主机监控页面
function MachineOnClick(ident,sourceName) {
  //打开系统监控页面。
  window.open('/sysadmin/machineMonitor/index?ident='+ident+'&sourceName='+sourceName, "_self");
}

//返回服务单元状态监控页面
function nodeMonitorOnClick(chainId,job) {
  //打开系统监控页面。
  window.open('/sysadmin/machineMonitor/nodeMonitor?chainId='+chainId+'&job='+job, "_self");
}

//启动方法调用
function startRemoteAppClick(data){
  rapid.confirm("确定要启动吗？", function(e) {
    if(e){
      rapid.post({
        url: "/sysadmin/remoteApp/startRemoteApp",
        data: {"cid": data},
        success: function (result) {
          rapid.success(result.msg);
          rapid("#grid").grid().reload();
        }
      });
    }
  });
}

//停止方法调用
function stopRemoteAppClick(data){
  rapid.confirm("确定要停止吗？", function(e) {
    if(e){
      rapid.post({
        url: "/sysadmin/remoteApp/stopRemoteApp",
        data: {"cid": data},
        success: function (result) {
          rapid.success(result.msg);
          rapid("#grid").grid().reload();
        }
      });
    }
  });
}

//部署方法调用
function uploadToRemoteClick(data){
  rapid.confirm("确定要部署吗？", function(e) {
    if(e){
      rapid.post({
        url: "/sysadmin/remoteApp/uploadToRemote",
        data: {"cid": data},
        success: function (result) {
          rapid.success(result.msg);
        }
      });
    }
  });
}
//远程更新方法调用
function updateRemoteAppClick(data){
  rapid.confirm("确定要更新吗？", function(e) {
    if(e){
      rapid.post({
        url: "/sysadmin/remoteApp/updateRemoteApp",
        data: {"cid": data},
        success: function (result) {
          rapid.success(result.msg);
          //刷新页面数据
          rapid("#grid").grid().reload();
        }
      });
    }
  });
}

//服务与配置变更管理 操作执行
function mocExecClick(data){
  rapid.confirm("确定要执行吗？", function(e) {
    if(e){
      rapid.post({
        url: "/sysadmin/remoteApp/mocExec",
        data: {"cid": data},
        success: function (result) {
          //用comfirm打印返回内容，需要用户确认
          rapid.confirm(JSON.stringify(result,null, 2), function(e) {});
          //刷新页面数据
          rapid("#grid").grid().reload();
        }
      });
    }
  });
}